﻿<?xml version="1.0" encoding="utf-8"?>
<RequestTemplates xmlns="http://schemas.commerceserver.net/2013/01/foundation/RequestTemplateDefinition">
  <RequestTemplate id="GetProductSummary" group="Catalog" cached="true" cacheExpiration="01:00:00" containsSensitiveData="true">
    <Descriptions>
      <Description value="Get Product Quick Summary" />
    </Descriptions>
    <Operation id="1" builder="QueryOperationBuilder" entity="Product">
      <Search builder="ModelSearchCriteriaBuilder">
        <Argument name="Id" alias="ProductId" />
        <Argument name="CatalogId" />
      </Search>
      <PropertiesToReturn>
        <Property name="Id" />
        <Property name="CatalogId" />
        <Property name="DisplayName" />
        <Property name="Image_filename" />
        <Property name="AlternativeImageName" />
        <Property name="Description" />
        <Property name="CatPath" />
        <Property name="ProductLandingPage" />
        <Property name="ListPrice" />
      </PropertiesToReturn>
      <Operation id="1-1" builder="QueryRelatedOperationBuilder" entity="Variant" relationshipName="Variants">
        <PropertiesToReturn>
          <Property name="Id" />
          <Property name="DisplayName" />
          <Property name ="Size"/>
          <Property name ="ProductColor"/>
        </PropertiesToReturn>
      </Operation>
    </Operation>
  </RequestTemplate>  
  
  <!-- Get Category With Child Products -->
  <RequestTemplate id="GetCategoryWithChildProducts" group="Catalog" cached="true" cacheExpiration="01:00:00" containsSensitiveData="true">
    <Descriptions>
      <Description value="Get Category With Child Products" />
    </Descriptions>
    <Operation id="1" builder="QueryOperationBuilder" entity="Category">
      <Search builder="ModelSearchCriteriaBuilder">
        <Argument name="Id" alias="CategoryId" />
        <Argument name="CatalogId" />
      </Search>
      <PropertiesToReturn>
        <Property name="Id" />
        <Property name="CatalogId" />
        <Property name="DisplayName" />
        <Property name="Description"/>
        <Property name="Image_filename"/>
      </PropertiesToReturn>
      <Operation id="1-1" builder="QueryRelatedOperationBuilder" entity="Product" relationshipName="ChildProducts">
        <Search builder="ModelSearchCriteriaBuilder">
          <Argument name="FirstItemIndex" />
          <Argument name="NumberOfItemsToReturn" value="10" />
          <Argument name="ReturnTotalItemCount" />
          <Argument name="Rank" />
          <Argument name="DisplayName" />
        </Search>
        <Sort>
          <Argument name="Rank" />
          <Argument name="DisplayName" />
          <Argument name="CurrentPrice" />
        </Sort>
        <PropertiesToReturn>
          <Property name="Id" />
          <Property name="CatalogId" />
          <Property name="DisplayName" />
          <Property name="ListPrice"/>
          <Property name="Description"/>
          <Property name="Image_filename"/>
        </PropertiesToReturn>
        <Operation id="1-1-1" builder="QueryRelatedOperationBuilder" entity="Variant" relationshipName="Variants">
          <PropertiesToReturn>
            <Property name="Id" />
            <Property name="DisplayName" />
            <Property name="InventoryCondition" />
          </PropertiesToReturn>
        </Operation>
      </Operation>
    </Operation>
  </RequestTemplate>

  <RequestTemplate id="CreateUser" group="Profile" cached="false">
    <Descriptions>
      <Description value="Create a user" />
    </Descriptions>
    <Operation id="1" builder="CreateOperationBuilder" entity="UserProfile" commerceArea="Profiles">
      <PropertiesToSet>
        <Argument name="Email" />
        <Argument name="Password" />
        <Argument name="ModifiedBy" />
        <Argument name="PasswordQuestion" />
        <Argument name="PasswordAnswer" />
      </PropertiesToSet>
      <PropertiesToReturn>
        <Property name="Id"/>
        <Property name="Email"/>
      </PropertiesToReturn>
    </Operation>
  </RequestTemplate>

  <RequestTemplate id="UpdateUser" group="Profile" cached="false">
    <Descriptions>
      <Description value="Update a user" />
    </Descriptions>
    <Operation id="1" builder="UpdateOperationBuilder" entity="UserProfile" commerceArea="Profiles">
      <Search>
        <Argument name="Id"/>
      </Search>
      <PropertiesToSet>
        <Argument name="PasswordQuestion" />
      </PropertiesToSet>
      <PropertiesToReturn>
        <Property name="Id"/>
        <Property name="Email"/>
        <Property name="PasswordQuestion"/>
      </PropertiesToReturn>
    </Operation>
  </RequestTemplate>

  <RequestTemplate id="DeleteUser" group="Profile" cached="false">
    <Descriptions>
      <Description value="Delete a user" />
    </Descriptions>
    <Operation id="1" builder="DeleteOperationBuilder" entity="UserProfile" commerceArea="Profiles">
      <Search>
        <Argument name="Email"/>
      </Search>
    </Operation>
  </RequestTemplate>
</RequestTemplates>